{template 'common/header'}
<script type="text/javascript" src="resource/js/lib/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="resource/js/lib/jquery-ui-1.10.3.min.js"></script>
<ul class="nav nav-tabs">
    <li {if $op =='post' && empty($id)}class="active"{/if}><a href="{php echo $this->createWebUrl('Paper', array('op' => 'post'));}">添加精美图文</a>
    </li>
    <li {if $_GPC['do'] == 'art'}class="active"{/if}><a href="{php echo $this->createWebUrl('art')}">导入文章</a></li>
    <li><a href="http://weixin.sogou.com/" target="_blank">查找更多文章</a></li>
</ul>
<script>
    require(['bootstrap'], function ($) {
        $('.btn').hover(function () {
            $(this).tooltip('show');
        }, function () {
            $(this).tooltip('hide');
        });
    });
</script>
{if !checksubmit(lead)}
<div class="main">
    <form action="" method="post" class="form-horizontal form" id="form">
        <div class="panel panel-default">
            <div class="panel-heading">导入文章</div>
            <div class="panel-body">

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 col-lg-2 control-label">文章链接</label>

                    <div class="col-xs-12 col-sm-8">
                        <input type="text" name="wxarticle" class="form-control" value=""/>
                    </div>
                </div>
                <div class="alert alert-warning" role="alert">直接将微信文章链接粘贴到上方提交即可。</div>
                <div class="form-group col-sm-12">

                    <input type="submit" name="lead" value="提交" class="btn btn-primary col-lg-1"/>
                    <input type="hidden" name="token" value="{$_W['token']}"/>
                </div>
            </div>
        </div>
    </form>
</div>
{/if}
{if checksubmit('lead')}
<div class="clearfix">
    <form class="form-horizontal form" action="" method="post" enctype="multipart/form-data">
        <div class="panel panel-default">
            <div class="panel-heading">文章管理</div>
            <div class="panel-body">
                <input type="hidden" name="id" value="{$item[id]}">

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">访问地址</label>
                    <div class="col-sm-8">
                        <p class="form-control-static">
                            <a class="preview_url"
                               href="{php echo $_W['siteroot'].'app/'.substr($this->createMobileUrl('detail',array('id'=>$item[id]),true),2);}"
                               target="_blank">
                                {php echo $_W['siteroot'].'app/'.substr($this->createMobileUrl('detail',array('id'=>$item[id]),true),2);}
                            </a>
                        </p>
                        <div class="help-block">如果设置了外链，会直接访问外链地址</div>
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开启评论</label>
                    <div class="col-sm-9 col-xs-12">
                        <div style="float: left">
                            <label for="isshow3" class="radio-inline">
                                <input type="radio" name="iscomment" value="0" id="isshow3" {if $item['iscomment']==0}checked{/if}> 开启</label>
                            <label for="isshow4" class="radio-inline">
                                <input type="radio" name="iscomment" value="1" id="isshow4" {if $item['iscomment']==1}checked{/if} > 关闭</label>
                        </div>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">标题</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" placeholder="" name="title" value="{$title}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">文章触发关键字</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="keyword" value="{$keywords}">
                        <div class="help-block">添加关键字以后,系统将生成一条图文规则,用户可以通过输入关键字来阅读文章</div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开启赞赏</label>
                    <div class="col-sm-9 col-xs-12">
                        <div style="float: left">
                            <label for="isadmire1" class="radio-inline">
                                <input type="radio" id="isadmire1" name="isadmire" onclick="sendtypeshow(false)"  value="0"{if $item['isadmire']==0}checked{/if}>开启</label>
                            <label for="isadmire2" class="radio-inline">
                                <input type="radio" id="isadmire2" name="isadmire" value="1" onclick="sendtypeshow(true)" {if $item['isadmire']==1}checked{/if}>关闭</label>
                        </div>
                    </div>
                </div>
                <div class="form-group model0">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">赞赏引导语</label>
                    <div class="col-sm-8">
                        <input type="text" class="form-control" placeholder="" name="admiretxt" value="{$item['admiretxt']}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">排序</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" placeholder="" name="displayorder" value="{$item['displayorder']}">
                        <span class="help-block">文章的显示顺序，越大则越靠前</span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">虚拟发布时间</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" name="createtime" class="form-control judge" style="padding-left: 12px; "
                               value="{if $id}{php echo date('Y-m-d H:i', $item['createtime'])}{else}{php echo date('Y-m-d H:i');}{/if}"
                               placeholder="虚拟发布时间 (格式: {php echo date('Y-m-d  H:i');})" bind-in="art_date_v" bind-de="{php echo date('Y-m-d H:i');}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">缩略图</label>
                    <div class="col-sm-9">
                        {php echo tpl_form_field_image('thumb', $pic)}
                        <span class="help-block">
                            建议图片大小为：400*240
                        </span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">文章类别</label>
                    <div class="col-sm-8 col-xs-12">
                        {php echo tpl_form_field_category_2level('category', $parent, $children, $pcate, $ccate)}
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">来源</label>
                    <div class="col-sm-9 col-xs-12">
                        <div class="input-group">
                            <input type="text" class="form-control" placeholder="图文消息的来源地址" name="outLink" value="{$item['outLink']}"/>
                            <span class="input-group-btn">
                                <button class="btn btn-default link_select" type="button"><i class="fa fa-external-link"></i> 系统链接</button>
                            </span>

                        </div>
                        <span>
                            也可以填写外表连接。如果填写连接，会跳转到此连接,转成短地址。<a target="_blank" href="http://www.dwz.cn/">短网址转换</a>
                             </span>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">简介</label>
                    <div class="col-sm-8 col-xs-12">
                        <textarea class="form-control" name="description" rows="5">{$item['description']}</textarea>
                    </div>
                </div>


                {if empty($item['outLink'])}
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">文章作者</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" id="author" name="author" value="{$item['author']}">
                    </div>
                </div>


                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">是否开启背景音乐</label>
                    <div class="col-sm-9">
                        <label for="status_01">
                            <input type="radio" name="bg_music_switch" value="1" class="js_music_open" id="status_01"{if $item['bg_music_switch']==1}checked{/if}/>开启
                        </label>

                        <label for="status_02">
                            <input type="radio" name="bg_music_switch" value="2" class="js_music_close" id="status_02" {if $item['bg_music_switch']==2}checked{/if}/>关闭</label>
                        <span class="help-block">如果关闭的话，前端不会出现音乐播放器</span>
                    </div>
                </div>
                <div class="form-group" id="js_music_div">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">音频链接</label>
                    <div class="col-sm-9 col-xs-12">
                        {php echo tpl_form_field_audio('musicurl', $item['musicurl']);}
                    <span class="help-block">选择上传的音频文件或直接输入URL地址，常用格式：mp3 (保证浏览网页的加载速度,上传音乐最大为 2MB
                        <!-- <a  href="http://mp.weixin.qq.com/s?__biz=MjM5MTM3MjMzMQ==&amp;mid=206141649&amp;idx=1&amp;sn=95b617a001b9d9371d4f66d73404be91##wechat_redirect" target="_blank">查看音乐上传帮助
                    </a>-->)
                    </span>

                    </div>
                </div>

                <div class="form-group clearfix">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">选择内容页面模板</label>
                    <div class="col-sm-8 col-xs-12">
                        {template 'a_tpl'}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label"></label>
                    <div class="col-sm-8">
                        <div class="help-block">
                            <label class="checkbox-inline">
                                <input type="checkbox" name="autolitpic" value="1"{if empty($pic)} checked{/if}>提取内容的第一个图片为缩略图
                            </label>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">内容</label>
                    <div class="col-sm-8">
                        {php echo tpl_ueditor('content', $content);}
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">一键拨号</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" id="tel" name="tel" value="{$item['tel']}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">阅读量</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" id="clickNum" name="clickNum" value="{$item['clickNum']}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-xs-12 col-sm-4 col-md-3 col-lg-2 control-label">点赞量</label>
                    <div class="col-sm-8 col-xs-12">
                        <input type="text" class="form-control" id="zanNum" name="zanNum" value="{$item['zanNum']}">
                    </div>
                </div>
                {/if}
            </div>
        </div>

        <div class="form-group">
            <div class="col-sm-12">
                <input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1">
                <input type="hidden" name="token" value="{$_W['token']}"/>
            </div>
        </div>
    </form>
</div>
<script type="text/javascript">
    require(['jquery', 'util'], function ($, u) {
        {if $item['bg_music_switch']==2}
            $("#js_music_div").toggleClass('hide', $(this).prop("checked"));
            {/if}

                $(".js_music_close").on("change", function () {
                    $("#js_music_div").toggleClass('hide', $(this).prop("checked"));
                });
                $(".js_music_open").on("change", function () {
                    $("#js_music_div").toggleClass('hide', !$(this).prop("checked"));
                });
                $('#credit1').click(function () {
                    $('#credit-status1').show();
                });
                $('#credit0').click(function () {
                    $('#credit-status1').hide();
                });

                $('.link_select').unbind('click').click(function(){
                    var ipt = $(this).parent().prev();
                    util.linkBrowser(function(href){
                        ipt.val(href);
                    });
                });
            });
            function sendtypeshow(sf){
                if (sf){
                    $(".model0").hide();
                } else {
                    $(".model0").show();
                }
            }
</script>
<script type="text/javascript">
    //放大图片
    $(function () {
        // 链接二维码
        $(".preview_url").mouseover(function (e) {
            var encodeurl = $(this).attr("href").replace(/&/g, "%26");
            var qrcodeimg = "<div id='qrcodeimg'><img src='http://qr.liantu.com/api.php?bg=f3f3f3&fg=ff0000&gc=222222&el=l&w=200&m=10&text=" + encodeurl + "' width='300' alt='二维码'/><\/div>";
            $("body").append(qrcodeimg); //把它追加到文档中
            $("#qrcodeimg").css({
                "z-index": 9999,
                "position": "absolute",
                "top": (e.pageY + 10) + "px",
                "left": (e.pageX + 10) + "px"
            }).show("fast");   //设置x坐标和y坐标，并且显示
        }).mouseout(function () {
            $("#qrcodeimg").remove();  //移除
        }).mousemove(function (e) {
            $("#qrcodeimg").css({
                "z-index": 9999,
                "position": "absolute",
                "top": (e.pageY + 10) + "px",
                "left": (e.pageX + 10) + "px"
            });   //设置x坐标和y坐标，并且显示
        });

    });
</script>
{/if}
<script>
    $(function () {
        window.optionchanged = false;
        $('#myTab a').click(function (e) {
            e.preventDefault();//阻止a链接的跳转行为
            $(this).tab('show');//显示当前选中的链接及关联的content
        })
    });
    require(['jquery', 'util'], function ($, u) {
        $(function () {
            u.editor($('.richtext')[0]);
        });
    });
</script>